<template>
  <!-- 添加或修改发票管理对话框 -->
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
    <!--开票信息明细-->
    <goods-invoice-detail-section :invoice-id="applyId"></goods-invoice-detail-section>
    <!--申请明细-->
    <goods-invoice-apply-detail-list-section :applyId="applyId"></goods-invoice-apply-detail-list-section>
    <!--核销记录-->
    <goods-invoice-detail-list-section :invoiceId="applyId" ></goods-invoice-detail-list-section>

    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {
  accMul,
  addAction,
  getAction,
  getById,
  updateAction
} from '@/api/manage'
  import {
    updateInvoice
  } from '@/api/develop/goodsInvoiceBatch'
  import GoodsInvoiceApplyDetailList from "@/views/develop/goodsInvoiceApplyDetail/GoodsInvoiceApplyDetailList.vue";
  import GoodsInvoiceApplyDetailListSection
    from "@/views/develop/goodsInvoiceApplyDetail/GoodsInvoiceApplyDetailListSection.vue";
  import GoodsInvoiceDetailListSection from "@/views/develop/goodsInvoiceDetail/GoodsInvoiceDetailListSection.vue";
import GoodsInvoiceDetailSection from "@/views/develop/goodsInvoice/GoodsInvoiceDetailSection.vue";

  export default {
    name: "GoodsInvoiceAllDetail",
    components: {
      GoodsInvoiceDetailSection,
      GoodsInvoiceDetailListSection, GoodsInvoiceApplyDetailListSection, GoodsInvoiceApplyDetailList},
    dicts: ['goods_supplier', 'goods_customer', 'fund_callback', 'yes_no', 'company', 'goods_customer',
      'invoice_back_status'
    ],
    data() {
      return {
        // 遮罩层
        loading: true,
        activeName: "first",
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 表单参数
        invoiceInfo: {},
        dataList: [],
        // 表单校验
        rules: {
          customerId: [{
            required: true,
            message: "客户名称不能为空",
            trigger: "blur"
          }],
        },
        total: 0,
        url: {
          list: '/goodsInvoiceDetail/goodsInvoiceDetail/list',
          listBatch: '/goodsSale/goodsSale/listBatchSale/',
          getById: '/goodsInvoice/goodsInvoice/',
          add: '/goodsInvoice/goodsInvoice/add',
          edit: '/goodsInvoice/goodsInvoice/edit',
        },
        applyId: null,
      };
    },
    created() {

    },
    methods: {

      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          no: null,
          amount: null,
          amountReal: null,
          remaining: null,
          customerId: null,
          customerName: null,
          taxNo: null,
          invoiceDate: null,
          invoiceCompany: null,
          fundCallback: null,
          backDate: null,
          drawerId: null,
          drawerName: null,
          saleId: this.$store.getters.userId,
          saleName: this.$store.getters.nickName,
          files: null,
          status: "0",
          delFlag: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          deptId: this.$store.getters.deptId,
          deptName: this.$store.getters.deptName,
        };
        this.resetForm("form");
      },
      /** 修改按钮操作 */
      handleDetail(row) {
        let that = this;
        this.applyId =row.id;
        that.reset();
        const id = row.id || that.ids;
        getById(that.url.getById, id).then(response => {
          that.invoiceInfo = response.data;
          that.open = true;
          that.title = "发票管理";
        });
      },


    }
  };
</script>
